# Tmux Configuration

# Base
set -g history-limit 65535

# Rebind prefix keybinding.
#unbind C-b
set -g prefix C-s

# Set colors
set-option -g default-terminal "screen-256color"

# Set reload key to r
bind r source-file ~/.tmux.conf \; display-message "Reload Config..."

# Count sessions start at 1
set -g base-index 1

# Use vim bindings
setw -g mode-keys vi

# Select the pane
bind -r k select-pane -U  # UP    ↑
bind -r j select-pane -D  # Down  ↓
bind -r h select-pane -L  # Left  ←
bind -r l select-pane -R  # Right →
bind -r e lastp           # Select the last pane
bind -r ^e last           # Select the last wiwiwiwindow

# Resize the pane size
bind -r ^k resizep -U 10
bind -r ^j resizep -D 10
bind -r ^h resizep -L 10
bind -r ^l resizep -R 10

# Split the pane
#unbind '"'
#unbind %
bind - splitw -v -c '#{pane-current-path}'  # verticality
bind | splitw -h -c '#{pane-current-path}'  # horizontally

# Set the window
set -g base-index 1       # Set the base index of the window to 1
set -g pane-base-index 1  # Set the base index of the pane to 1

# Set the title bar
set -g set-titles on
set -g set-titles-string '#(whoami) :: #h :: #(curl ipecho.net/plain;echo)'

# Set mouse
set -g mouse on

# Set status bar
set -g status on
set -g status-keys vi
set -g status-bg black
set -g status-fg white
set -g status-justify centre
set -g status-position bottom
set -g status-interval 5
set -g status-left '#[fg=green][#S:#{session_group}] #[fg=black]'
set -g status-left-length 40
set -g status-left-style default
set -g status-right '#[fg=green,bg=default,bright] #[fg=white,bg=default]%a %H:%M:%S #[fg=blue]%Y-%m-%d '
set -g status-right-length 140
set -g status-right-style default

# Set the window status
set -wg window-status-current-format "[#I:#W#F].[#P:#T]"
set -wg window-status-separator ""
set -wg window-status-current-style "bg=red"
set -wg window-status-last-style "fg=red"

set -g message-style "bg=#202529, fg=#91A8BA"
setw -g automatic-rename off
setw -g allow-rename off

# Copy and Paste from/to the system clipboard
# For Linux with xclip
bind C-c run 'tmux save-buffer - | xclip -i -sel clipboard'
bind C-v run 'tmux set-buffer "${xclip -o -sel clipboard}"; tmux paste-buffer'
# For Mac with reattach-to-user-namespace
#bind C-c run 'tmux save-buffer - | reattach-to-user-namespace pbcopy'
#bind C-v run 'reattach-to-user-namespace pbpaste | tmux load-buffer - \; paste-buffer -d'
#bind -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel 'reattach-to-user-namespace pbcopy'
#bind -T copy-mode-vi MouseDragEnd1Pane send -X copy-pipe-and-cancel 'pbcopy'


###### Plugins ######
#set -g @plugin 'tmux-plugins/tpm'
#set -g @plugin 'tmux-plugins/tmux-sensible'
#
#run '~/.tmux/plugins/tpm/tmp'
